﻿package component.tree.web.view;

import java.util.List;

import component.tree.util.ConfigUtil;


public class BaseTreeView extends HtmlView {
	
	public final static String DIV_ID_PREX = "div_";//div的id的前缀
	public final static String IMAGE1_ID_PREX = "image1_";//虚线图片的id的前缀
	public final static String IMAGE2_ID_PREX = "image2_";//是否目录图片的id的前缀
	public final static String CHECKBOX_NAME_PREX = "child_";//checkbox的name的前缀
	
	public final static String LINE_BREAK = "\n"; //换行符号
	public final static String SEPARATOR = "\t"; //分隔符号
	public final static String SPACES = "  "; //空格
	
	public BaseTreeView(){
		
	}
	
	public BaseTreeView(String context,List treeList){
		this.context = context;
		this.treeList = treeList;
	}
	
	public BaseTreeView(String treeObj,String context,List treeList){
		this.treeObj = treeObj;
		this.context = context;
		this.treeList = treeList;
	}
	
	protected void setInitJs(StringBuffer sb){
		this.startScript(sb);
		
		sb.append("var "+this.treeObj+" = new component.tree.Tree('"+this.treeObj+"','"+context+"');");
		this.setLineBreak(sb);
		
		sb.append(this.treeObj + ".condition = \"" + this.condition  + "\";");
		this.setLineBreak(sb);
		
		sb.append(this.treeObj+".treeMap.put('isUseBaseIcon','"+this.isUseBaseIcon+"');");
		this.setLineBreak(sb);
		sb.append(this.treeObj+".treeMap.put('isUseLines','"+this.isUseLines+"');");
		this.setLineBreak(sb);
		sb.append(this.treeObj+".treeMap.put('isUseIcons','"+this.isUseIcons+"');");
		this.setLineBreak(sb);
		sb.append(this.treeObj+".treeMap.put('isTarget','"+this.isTarget+"');");
		this.setLineBreak(sb);
		sb.append(this.treeObj+".treeMap.put('isSelectMore','"+this.isSelectMore+"');");
		this.setLineBreak(sb);
		sb.append(this.treeObj+".treeMap.put('isSelectFolder','"+this.isSelectFolder+"');");
		this.setLineBreak(sb);
		sb.append(this.treeObj+".treeMap.put('isLoadAll','"+this.isLoadAll+"');");
		this.setLineBreak(sb);
		sb.append(this.treeObj+".treeMap.put('firstShowLevel','"+this.firstShowLevel+"');");
		this.setLineBreak(sb);
		sb.append(this.treeObj+".componentId='"+this.componentId+"';");
		this.setLineBreak(sb);
		
		if(this.firstShowLevel>1){
			sb.append(this.treeObj+".isOpen=false;");
			this.setLineBreak(sb);
		}
		
		//参数开始
		sb.append(this.treeObj + ".paras='");
		sb.append("&title="+this.title);	
		sb.append("&id="+this.treeObj);
		sb.append("&componentId="+this.componentId);
		sb.append("&isUseBaseIcon="+this.isUseBaseIcon);
		sb.append("&isLoadAll="+this.isLoadAll);
		sb.append("&firstShowLevel="+this.firstShowLevel);
		sb.append("&isSelectMore="+this.isSelectMore);
		sb.append("&isSelectFolder="+this.isSelectFolder);
		sb.append("&isUseLines="+this.isUseLines);
		sb.append("&isUseIcons="+this.isUseIcons);
		sb.append("&isSearch="+this.isSearch);
		sb.append("';");
		this.setLineBreak(sb);
		//参数结束
		
		this.endScript(sb);
	}
	
	protected String selectIds;
	
	protected String condition;
	protected String title = "测试树";//树的名称
	protected String treeObj;//js对象
	protected String componentId;
	protected String rootId="0";
	
	protected List treeList;
	
	protected String orderField;//排序字段
	
	protected boolean isUseBaseIcon = true;
	
	protected boolean isSearch = false;//是否有搜索功能
	protected boolean isSearchAble = false;//是否过滤数据
	protected String searchName;//搜索的名称
	protected boolean isRefresh = false;//是否刷新数据
	
	protected boolean isUseLines = true;//是否使用虚线连着
	protected boolean isUseIcons = true;//是否使用图片
	protected boolean isTarget = false;//是否有链接
	protected boolean isSelectMore = false;//是否能够选择多个节点，如果是就用checkbox
	protected boolean isSelectFolder = true;//是否能够选择目录
	protected boolean isLoadAll = false;//是否一次性加载还是动态加载
	protected int firstShowLevel = 1;//第一次显示几层
	protected boolean isCreateCode = false;//为了生成的html代码好看就设为true,但是会出现一些空格,导致树型不好看
	
	protected String url;
	protected String target;
	
	private boolean isShowClearBtn;
	private boolean isShowFirstBtn;
	
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getTreeObj() {
		return treeObj;
	}

	public void setTreeObj(String treeObj) {
		this.treeObj = treeObj;
	}
	
	public void setTreeList(List treeList) {
		this.treeList = treeList;
	}
	
	public List getTreeList() {
		return treeList;
	}
	
	public boolean isUseBaseIcon() {
		return isUseBaseIcon;
	}

	public void setUseBaseIcon(boolean isUseBaseIcon) {
		this.isUseBaseIcon = isUseBaseIcon;
	}
	
	public boolean isUseLines() {
		return isUseLines;
	}

	public void setUseLines(boolean isUseLines) {
		this.isUseLines = isUseLines;
	}

	public boolean isUseIcons() {
		return isUseIcons;
	}

	public void setUseIcons(boolean isUseIcons) {
		this.isUseIcons = isUseIcons;
	}

	public boolean isSelectMore() {
		return isSelectMore;
	}

	public void setSelectMore(boolean isSelectMore) {
		this.isSelectMore = isSelectMore;
	}

	public boolean isSelectFolder() {
		return isSelectFolder;
	}

	public void setSelectFolder(boolean isSelectFolder) {
		this.isSelectFolder = isSelectFolder;
	}

	public boolean isLoadAll() {
		return isLoadAll;
	}

	public void setLoadAll(boolean isLoadAll) {
		this.isLoadAll = isLoadAll;
	}

	public int getFirstShowLevel() {
		return firstShowLevel;
	}

	public void setFirstShowLevel(int firstShowLevel) {
		this.firstShowLevel = firstShowLevel;
	}

	public boolean isTarget() {
		return isTarget;
	}

	public void setTarget(boolean isTarget) {
		this.isTarget = isTarget;
	}

	public String getComponentId() {
		return componentId;
	}

	public void setComponentId(String componentId) {
		this.componentId = componentId;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getTarget() {
		return target;
	}

	public void setTarget(String target) {
		this.target = target;
	}

	public boolean isSearch() {
		return isSearch;
	}

	public void setSearch(boolean isSearch) {
		this.isSearch = isSearch;
	}

	public String getSearchName() {
		return searchName;
	}

	public void setSearchName(String searchName) {
		this.searchName = searchName;
	}

	public String getCondition() {
		return condition;
	}

	public void setCondition(String condition) {
		this.condition = condition;
	}

	public boolean isRefresh() {
		return isRefresh;
	}

	public void setRefresh(boolean isRefresh) {
		this.isRefresh = isRefresh;
	}

	public boolean isSearchAble() {
		return isSearchAble;
	}

	public void setSearchAble(boolean isSearchAble) {
		this.isSearchAble = isSearchAble;
	}

	public String getOrderField() {
		return orderField;
	}

	public void setOrderField(String orderField) {
		this.orderField = orderField;
	}

	public String getSelectIds() {
		return selectIds;
	}

	public void setSelectIds(String selectIds) {
		this.selectIds = selectIds;
	}

	public boolean isShowClearBtn() {
		return isShowClearBtn;
	}

	public void setShowClearBtn(boolean isShowClearBtn) {
		this.isShowClearBtn = isShowClearBtn;
	}

	public boolean isShowFirstBtn() {
		return isShowFirstBtn;
	}

	public void setShowFirstBtn(boolean isShowFirstBtn) {
		this.isShowFirstBtn = isShowFirstBtn;
	}
	
	
}
